package org.douxiaoban.client.activity;

import java.util.ArrayList;

import org.douxiaoban.client.R;
import org.douxiaoban.client.adapter.MiniBlogAdapter;
import org.douxiaoban.client.adapter.MiniBlogAdapter.ClickCallback;
import org.douxiaoban.client.api.DoubanList.DoubanListType;
import org.douxiaoban.client.api.MiniBlogList;
import org.douxiaoban.client.api.MiniBlogList.SendType;
import org.douxiaoban.client.app.App;
import org.douxiaoban.client.widget.TitleStyle;
import org.douxiaoban.data.MiniBlogItemData;

import android.os.Bundle;
import android.view.View;
import android.view.Window;

import com.mobclick.android.MobclickAgent;

public class MiniBlogActivity extends BaseActivity implements ClickCallback {

	// static{
	// AdManager.init(Assistant.AD_YOUMI_KEY, Assistant.AD_YOUMI_SCRET, 30,
	// false, 0.1);
	// }
	private ArrayList<MiniBlogItemData> m_listMiniBlog;
	private MiniBlogList mMbList;
	private TitleStyle mTitle;

	@Override
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);

		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		this.setContentView(R.layout.miniblog_home);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
				R.layout.custom_title);

		mTitle = new TitleStyle(this);
		mTitle.initTitleStyle();
		mTitle.initPageController(1, 1);
		mTitle.setTitle(getString(R.string.miniblog));

		MiniBlogAdapter adapter = new MiniBlogAdapter(this);
		View view = findViewById(R.id.miniblogView);
		mMbList = new MiniBlogList(this, adapter,
				DoubanListType.CONTACTS_MINIBLOG, view, App.userId);
		// m_editText = (EditText)findViewById(R.id.panelEdit);
		adapter.setListView(mMbList.getListView());
		adapter.setList(mMbList);
		mMbList.refresh();
		mTitle.initWriteMiniblog(mMbList);
	}

	// 点击回应那按钮
	@Override
	public void revBtnClick(String title, SendType type, String str) {
		mMbList.revBtnClick(title, type, str);
	}

	// 点击头像到用户主页
	@Override
	public void avatarClick(String userName, String userId) {
		mMbList.avatarClick(userName, userId);
	}

	@Override
	public void itemClick(MiniBlogItemData data) {
		// mMbList.clickEvent(data);
	}

}
